<?php
namespace Pw\MainBundle\Entity;

use Pw\MainBundle\Entity\Talent;
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Validator\Constraints as Assert;
class TalentType
{
	private $id;
	private $name;
//	private $color;
	private $description;

	/**
	* @var Doctrine\Common\Collections\ArrayCollection
	*/
    private $talents;

	public function __construct() {
		$this->talents = new ArrayCollection();
	}

	public static function loadValidatorMetadata(ClassMetadata $metadata)
    {
		$metadata->addConstraint(new UniqueEntity(array('fields' => 'name')));
		//Name
		$metadata->addPropertyConstraint('name', new Assert\NotBlank());
        $metadata->addPropertyConstraint('name', new Assert\Length(array("max" => 20)));
		//Color
//		$metadata->addPropertyConstraint('color', new Assert\NotBlank());
//        $metadata->addPropertyConstraint('color', new Assert\Length(array("max" => 10)));
	}

	public function getArray4JSON(){
		$res = array();
		$res['name'] = $this->name;
		return $res;
	}

    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set name
     *
     * @param string $name
     * @return Role
     */
    public function setName($name)
    {
        $this->name = $name;
    
        return $this;
    }

    /**
     * Get name
     *
     * @return string 
     */
    public function getName()
    {
        return $this->name;
    }
	
    public function setDescription($description)
    {
        $this->description = $description;
    
        return $this;
    }
    public function getDescription()
    {
        return $this->description;
    }


    /**
     * Add talents
     *
     * @param \Pw\MainBundle\Entity\Talent $talents
     * @return TalentType
     */
    public function addTalent(\Pw\MainBundle\Entity\Talent $talents)
    {
        $this->talents[] = $talents;
    
        return $this;
    }

    /**
     * Remove talents
     *
     * @param \Pw\MainBundle\Entity\Talent $talents
     */
    public function removeTalent(\Pw\MainBundle\Entity\Talent $talents)
    {
        $this->talents->removeElement($talents);
    }

    /**
     * Get talents
     *
     * @return \Doctrine\Common\Collections\Collection 
     */
    public function getTalents()
    {
        return $this->talents;
    }
}